package cn.wit.test;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

public class DemoFile {
	
	//创建文件
	@Test
	public void test() throws IOException {
		
		File directory = new File("D:");
		
		File file = new File(directory,"test\\test.text");
		
		boolean isCreated = file.createNewFile();
		
		System.out.println(isCreated);
		
		file.delete();//删除文件
		
	}
	
	
	//创建目录
	@Test
	public void testDirectory() throws IOException {
		
		File file =new File("D:\\test");
		
		file.mkdir();//创建目录
		
		file.delete();
		
		File file1 = new File("D:\\test\\day01");
		
		file1.mkdirs();//创建多个目录
		
		file1.delete();//目录只能一级一级得删除
		
		File file2 = new File("test.java");
		
		file2.createNewFile();//相对项目得路径
		
		System.out.println(file2.getAbsolutePath());//获取文件得绝对路径
	}

}
